<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AlterAddCallProToTemplate extends Migrator
{
    public function up()
    {
        $table = 'template';
        $name = 'CPS话费';
        $domain = env('app.api_url');
        $list = \think\facade\Db::table($table)->where('template_name', $name)->findOrEmpty();
        $data['created_at'] = date("Y-m-d H:i:s");
        if (empty($list)) {
            $data['template_name'] = $name;
            $data['pre_url'] = "/jxcall/index";
            $data['template_img'] = $domain.'/template/call_promotion.jpg';
            \think\facade\Db::name($table)->insert($data);
        }
    }

    public function down()
    {
        \app\model\Template::query()->where('name', 'CPS话费')->delete();
    }
}
